package com.yangmin.springcloud.controller;

import com.netflix.hystrix.contrib.javanica.annotation.DefaultProperties;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import com.yangmin.springcloud.service.PaymentHystrixService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@Slf4j
@DefaultProperties(defaultFallback = "payment_Global_FallbackMethod")
public class PaymentHystrixComsumerController implements PaymentHystrixService {
    @Resource
    PaymentHystrixService paymentHystrixService;

    @Override
    @GetMapping("/comsumer/histrix/ok/{id}")
    public String paymentHistrixInfo_OK(@PathVariable("id") Integer id) {
        return paymentHystrixService.paymentHistrixInfo_OK(id);
    }

    @Override
//    @HystrixCommand
    @GetMapping("/comsumer/histrix/outtime/{id}")
    public String paymentHistrixInfo_Outtime(Integer id) {
        return paymentHystrixService.paymentHistrixInfo_Outtime(id);
    }

    public String payment_Global_FallbackMethod()
    {
        return "我是消费者80,对方支付系统繁忙请10秒钟后再试或者自己运行出错请检查自己,o(╥﹏╥)o";
    }
}
